#include <iostream>
#include <string>
using namespace std;
unsigned int fd(char i[], char j, int k) {
	for (int a = 0; a < k; a ++)
		if (i[a] == j) return a + 1;
	return 0;
}
int main() {
	int x;
	char z;
	cin >> x;
	const int X = x + 2;
	char y[X];
	for (int a = 0; a < x; a ++) cin >> y[a];
	cin >> z;
	int b = fd(y, z, x);
	while (b == 0) {
		cin >> z;
		b = fd(y, z, x);
	}
	cout << b;
	return 0;
}
